﻿using System;
using System.Web.Mvc;
using System.Web.Routing;
using Common;
using Common.WebApplication;
using Ninject;

namespace NinjectManager
{
    public class NinjectControllerFactory : DefaultControllerFactory
    {
            private readonly IKernel ninjectKernel;
            public NinjectControllerFactory()
            {
                ninjectKernel = Ioc.Container;
            }

            protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)
            {
                return (controllerType == null) ? null : (IController)ninjectKernel.Get(controllerType);
            }
    }
}